- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 874
fix: Event not presented to client when __type is missing in LiveQuery server response #1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: Event not presented to client when __type is missing in LiveQuery server response #1863
Conversation
…ormat but PFDecoder.m checks for __type key which is missing as shown in below example so this fix will add "__type ":"Object" key-value if dictionary has className and objectId representing PFObject.
"object":{
    "desc": "Technology",
    "createdAt": "2020-10-03T19:34:16.823Z",
    "updatedAt": "2025-09-27T17:55:02.360Z",
    "image_name": "technology.png",
    "className": "categories",
    "objectId": "kHnBntWHHW"
},
"original": {
    "desc": "Technologyy",
    "createdAt": "2020-10-03T19:34:16.823Z",
    "updatedAt": "2025-09-27T17:54:10.800Z",
    "image_name": "technology.png",
    "className": "categories",
    "objectId": "kHnBntWHHW"
}
    | 🚀 Thanks for opening this pull request! | 
| 📝 WalkthroughWalkthroughInjects "__type":"Object" into dictionaries missing  Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  participant Caller as Caller
  participant PFDecoder as PFDecoder.decodeDictionary
  participant ObjBranch as Object Branch
  participant PFObject as PFObject
  Caller->>PFDecoder: decodeDictionary(data)
  alt __type missing AND className & objectId present
    note right of PFDecoder #DDEBF7: Inject "__type":"Object" into mutable copy
    PFDecoder->>ObjBranch: route with type="Object"
  else __type present
    PFDecoder->>ObjBranch: route based on __type
  end
  ObjBranch->>PFDecoder: recursively decode remaining fields
  ObjBranch->>PFObject: construct with defaultClassName, objectId, data
  PFDecoder-->>Caller: decoded PFObject
sequenceDiagram
  autonumber
  participant Server as Server Event
  participant ClientBefore as LiveQuery Client (before)
  participant Decoder as PFDecoder.object()
  participant App as App Code
  Server-->>ClientBefore: object dictionary (className, objectId, fields)
  ClientBefore->>ClientBefore: validate className & objectId
  ClientBefore->>Decoder: decode(...) as T
  alt success
    ClientBefore-->>App: return T
  else failure
    ClientBefore-->>App: throw decoding error
  end
sequenceDiagram
  autonumber
  participant Server as Server Event
  participant ClientNow as LiveQuery Client (now)
  participant App as App Code
  Server-->>ClientNow: object dictionary (className, objectId, fields)
  ClientNow->>ClientNow: validate className & objectId
  note right of ClientNow #F7F3E8: Typed decoding step removed
  ClientNow-->>App: proceed without returning typed T here
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment  | 
| ✅ Snyk checks have passed. No issues have been found so far.
 💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
- Parse/Parse/Source/PFDecoder.m(1 hunks)
- ParseLiveQuery/ParseLiveQuery/Internal/ClientPrivate.swift(0 hunks)
💤 Files with no reviewable changes (1)
- ParseLiveQuery/ParseLiveQuery/Internal/ClientPrivate.swift
…nd on the presence of additional data fields so that bare pointer stubs continue to fall back to the legacy dictionary path.
| @mtrezza could you please review this? | 
| Hello, if my PR is in right direction then pls help. I have I am trying to run tests from /parse folder and also tried from root folder but failing. Not able to figure.  | 
| Sharing build log.  | 
| @ashish-naik I'm working on fixing the build #1865 if you want to take a look | 
| I don't have understanding of the change you are making but looking forward to it. Could you also take a look at this PR whether it is in right direction? live query functionality in my code is working with this change. | 
| This looks good to me! | 
| Thanks. Will wait for your PR to run the tests before merging ? | 
| iOS tests passed. | 
Issue Description
Response from websocket server does not include "__type":"Object" but PFDecoder expects this otherwise events failed to be caught.
Closes: Issue #1832
Approach
LiveryQuery server response sends data or events in "object":jsonf= format but PFDecoder.m checks for __type key which is missing as shown in below example so this fix will add "__type ":"Object" key-value if dictionary has className and objectId representing PFObject.
Requesting review.
Summary by CodeRabbit
Bug Fixes
Refactor